<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />


<atleap:constants className="com.blandware.atleap.model.core.MenuItem" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_LOCALES_COLLECTION_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="OWNER_INFO_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="MENU_ITEM_PARENTS_LIST_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="HTML_TEXT_FIELD_MAX_LENGTH" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="TARGET_IDENTIFIER_KEY_PREFIX" scope="page" />
<atleap:content identifier="information" ignore="true" uri="/core/menuItem/callCreate"/>
<c:set var="parentsList" value="${requestScope[pageScope.MENU_ITEM_PARENTS_LIST_KEY]}" />
<c:set var="path" value="" />
<c:if test="${parentsList != null}">
	<atleap:iterator items="${parentsList}" var="parentItem" statusVar="listStatus">
		<atleap:fieldValue valueMap="${parentItem.title}" var="titleKey" />
		<atleap:message key="${titleKey}" var="titleMsg" ignore="true" />
		<c:if test="${empty titleMsg}">
			<c:set var="titleMsg" value="${titleKey}" />
		</c:if>
		<atleap:message key="core.menuItem.form.goToItem" arg0="${titleMsg}" var="linkTitle" />
		<c:set var="path" value="${path}${titleMsg}" />
		<c:if test="${!listStatus.last}">
			<c:set var="path" value="${path}&nbsp;&gt;&nbsp;" />
		</c:if>
	</atleap:iterator>
</c:if>
<atleap:form action="core/menuItem/create" method="POST" validateOnSubmit="false">
    <table cellpadding="0"  cellspacing="0" border="0" class="modificationTable">
		<c:if test="${!empty path}">
			<tr>
				<th colspan="2" style="text-align: center;">
					<atleap:message key="core.menuItem.form.path" arg0="${path}" />
				</th>
			</tr>
		</c:if>
        <c:if test="${!empty requestScope[pageScope.OWNER_INFO_KEY]}">
			<tr>
				<th>
					<atleap:message key="core.menuItem.form.ownerInfo" />
				</th>
				<td>
					${requestScope[pageScope.OWNER_INFO_KEY]}
				</td>
			</tr>
		</c:if>
        <tr>
            <th>
                <atleap:label property="location" key="core.menuItem.form.location" colon="false" helpTip="true" />
            </th>
            <td nowrap="nowrap">
				<html:text property="location" styleClass="text"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleId="locationInput" />
				<a href="javascript:void(0);" title="<atleap:message key="core.commons.buttons.browseLinks" />" onclick="browseInPopup('<atleap:rewriteUrl action="/core/browser/browseContentPages" addLocaleSuffix="false"><atleap:param name="opening" value="true" /></atleap:rewriteUrl>', 'locationInput', 800, 500); return false;">
					<img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/hyperlink.gif" />" title="<atleap:message key="core.commons.buttons.browseLinks" />" alt="<atleap:message key="core.commons.buttons.browseLinks" />"  /></a>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <atleap:label property="title" key="core.menuItem.form.title" colon="false" helpTip="true" />
            </td>
        </tr>
        <atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
            <tr>
                <th>
					<div class="languageField">
						<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
						<c:if test="${empty languageTitle}">
							<c:set var="languageTitle" value="${contentLocale.identifier}" />
						</c:if>
						*&nbsp;<atleap:message key="core.menuItem.form.language" />:&nbsp;${languageTitle}
					</div>
                </th>
				<td>
					<html:text property="title(${contentLocale.identifier})"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
				</td>
            </tr>
        </atleap:iterator>
        <tr>
            <td colspan="2" align="center">
                <atleap:label property="toolTip" key="core.menuItem.form.toolTip" colon="false" helpTip="true" />
            </td>
        </tr>
        <atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
            <tr>
                <th>
					<div class="languageField">
						<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
						<c:if test="${empty languageTitle}">
							<c:set var="languageTitle" value="${contentLocale.identifier}" />
						</c:if>
						<atleap:message key="core.menuItem.form.language" />:&nbsp;${languageTitle}
					</div>
                </th>
                <td>
                    <html:text property="toolTip(${contentLocale.identifier})"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
                </td>
            </tr>
        </atleap:iterator>
        <tr>
            <td colspan="2"></td>
        </tr>
        <tr>
            <th>
                <atleap:label property="align" styleClass="label" key="core.menuItem.form.align" colon="false" helpTip="true" />
            </th>
            <td>
                <html:select property="align">
                    <html:option value="" />
                    <html:option value="${pageScope.ALIGN_LEFT}"><atleap:message key="core.menuItem.form.align.${pageScope.ALIGN_LEFT}" /></html:option>
                    <html:option value="${pageScope.ALIGN_RIGHT}"><atleap:message key="core.menuItem.form.align.${pageScope.ALIGN_RIGHT}" /></html:option>
                    <html:option value="${pageScope.ALIGN_BOTTOM}"><atleap:message key="core.menuItem.form.align.${pageScope.ALIGN_BOTTOM}" /></html:option>
                    <html:option value="${pageScope.ALIGN_TOP}"><atleap:message key="core.menuItem.form.align.${pageScope.ALIGN_TOP}" /></html:option>
                    <html:option value="${pageScope.ALIGN_MIDDLE}"><atleap:message key="core.menuItem.form.align.${pageScope.ALIGN_MIDDLE}" /></html:option>
                    <html:option value="${pageScope.ALIGN_BASELINE}"><atleap:message key="core.menuItem.form.align.${pageScope.ALIGN_BASELINE}" /></html:option>
                    <html:option value="${pageScope.ALIGN_ABS_BOTTOM}"><atleap:message key="core.menuItem.form.align.${pageScope.ALIGN_ABS_BOTTOM}" /></html:option>
                    <html:option value="${pageScope.ALIGN_ABS_MIDDLE}"><atleap:message key="core.menuItem.form.align.${pageScope.ALIGN_ABS_MIDDLE}" /></html:option>
                    <html:option value="${pageScope.ALIGN_TEXT_TOP}"><atleap:message key="core.menuItem.form.align.${pageScope.ALIGN_TEXT_TOP}" /></html:option>
                </html:select>
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="style" styleClass="label" key="core.menuItem.form.style" colon="false" helpTip="true" />
            </th>
            <td>
                <html:text property="style"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="styleClass" styleClass="label" key="core.menuItem.form.styleClass" colon="false" helpTip="true" />
            </th>
            <td>
                <html:text property="styleClass"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="styleId" styleClass="label" key="core.menuItem.form.styleId" colon="false" helpTip="true" />
            </th>
            <td>
                <html:text property="styleId"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="image" styleClass="label" key="core.menuItem.form.image" colon="false" helpTip="true" />
            </th>
            <td nowrap="nowrap">
				<html:text property="image"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" styleId="imageInput" />
				<a href="javascript:void(0);" onclick="browseInPopup('<atleap:rewriteUrl action="/core/browser/browseImages" addLocaleSuffix="false"><atleap:param name="opening" value="true" /></atleap:rewriteUrl>', 'imageInput', 800, 500); return false;" title="<atleap:message key="core.commons.buttons.browseImages" />">
					<img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/browseImages.gif" />" title="<atleap:message key="core.commons.buttons.browseImages" />" alt="<atleap:message key="core.commons.buttons.browseImages" />" /></a>
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="altImage" styleClass="label" key="core.menuItem.form.altImage" colon="false" helpTip="true" />
            </th>
            <td nowrap="nowrap">
				<html:text property="altImage"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" styleId="altImageInput" />
				<a href="javascript:void(0);" onclick="browseInPopup('<atleap:rewriteUrl action="/core/browser/browseImages" addLocaleSuffix="false"><atleap:param name="opening" value="true" /></atleap:rewriteUrl>', 'altImageInput', 800, 500); return false;" title="<atleap:message key="core.commons.buttons.browseImages" />">
						<img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/browseImages.gif" />" title="<atleap:message key="core.commons.buttons.browseImages" />" alt="<atleap:message key="core.commons.buttons.browseImages" />" /></a>
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="target" styleClass="label" key="core.menuItem.form.target" colon="false" helpTip="true" />
            </th>
            <td>
                <html:text property="target"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
                <br />
                <select name="targetsList" onchange="var index = this.selectedIndex; var target = (index == 0) ? '' : this.options[index].value; var e = this.form.elements['target']; e.value = target;">
                    <option value="-1">&nbsp;</option>
                    <atleap:iterator items="${linkTargets}" var="targetId">
                        <c:set var="value">
                            <c:out value="${targetId}" escapeXml="true" />
                        </c:set>
                        <c:set var="selected" value=""/>
                        <c:if test="${targetId == menuItemForm.target}">
                            <c:set var="selected">selected="selected"</c:set>
                        </c:if>
                        <option value="${value}" ${selected}><atleap:message key="${pageScope.TARGET_IDENTIFIER_KEY_PREFIX}${targetId}" /> (${value})</option>
                    </atleap:iterator>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="hreflang" styleClass="label" key="core.menuItem.form.hreflang" colon="false" helpTip="true" />
            </th>
            <td>
                <html:text property="hreflang"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
                <br />
                <select name="hreflangsList" onchange="var index = this.selectedIndex; var hreflang = (index == 0) ? '' : this.options[index].value; var e = this.form.elements['hreflang']; e.value = hreflang;">
                    <option value="-1">&nbsp;</option>
                    <atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
                        <c:set var="value">
                            <c:out value="${contentLocale.identifier}" escapeXml="true" />
                        </c:set>
                        <c:set var="selected" value=""/>
                        <c:if test="${contentLocale.identifier == menuItemForm.hreflang}">
                            <c:set var="selected">selected="selected"</c:set>
                        </c:if>
                        <option value="${value}" ${selected}><atleap:fieldValue valueMap="${contentLocale.title}" filter="true"/></option>
                    </atleap:iterator>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="visibility" styleClass="label" key="core.menuItem.form.visibility" colon="false" helpTip="true" />
            </th>
            <td>
                <html:select property="visibility">
                    <html:option value="${pageScope.VISIBILITY_VISIBLE}"><atleap:message key="core.menuItem.form.visibility.${pageScope.VISIBILITY_VISIBLE}" /></html:option>
                    <html:option value="${pageScope.VISIBILITY_INVISIBLE}"><atleap:message key="core.menuItem.form.visibility.${pageScope.VISIBILITY_INVISIBLE}" /></html:option>
                    <html:option value="${pageScope.VISIBILITY_HERITABLE}"><atleap:message key="core.menuItem.form.visibility.${pageScope.VISIBILITY_HERITABLE}" /></html:option>
                </html:select>
            </td>
        </tr>
    </table>
	<br />
	<html:hidden property="ownerId" />
    <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.create" /></atleap:submit>
    <atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.cancel" /></atleap:cancel>
</atleap:form>
